#include<fcntl.h>
#include<unistd.h>
#include<stdio.h>
#include<string.h>
int main(){
    int fd = open("1.txt",O_RDWR | O_CREAT,0664);
    if(fd < 0){
        perror("open");
        return 0;
    }
    printf("%d\n",fd);
    //while(1){

    //}
    printf("open sucess\n");
    //测试写
    const char* buf = "Linux is so easy";
    ssize_t fsize = write(fd,buf,strlen(buf));
    printf("fsize = %ld\n",fsize);
    //测试读
    lseek(fd,0,SEEK_SET);
    char temp[1024] = {0};
    ssize_t rd_size = read(fd,temp,sizeof(temp) - 1);
    printf("rd_size = %ld\n",rd_size);
    close(fd);
    return 0;
}
